<?php

declare(strict_types=1);

namespace app\admin\service\system;

use app\common\model\circle\CircleModel;
use app\common\model\dynamic\DynamicModel;
use app\common\model\goods\GoodsModel;
use Dengje\Pxy\BaseService;

class ExpressService extends BaseService
{
    protected $model = null;


    public function __construct()
    {
        $this->model =  new \app\common\model\system\ExpressModel();
    }

    public function list()
    {
        $where = [];
        $status = request()->get('status', 0);
        if ($status) $where[] = ['status', '=', $status];
        if(request()->get('page_size/d')){
            $list = $this->model->where($where)->order(['sort' => 'asc', 'id' => 'desc'])->paginate(request()->get('page_size/d', 10));
        }else{
            $list = $this->model->where($where)->order(['sort' => 'asc', 'id' => 'desc'])->select();
        }
        
        
        return $list;
    }

    public function detail($id)
    {
        $detail = $this->model->where('id', $id)->find();
        return $detail;
    }

    public function create($data)
    {
    
        $banner = $this->model->create($data);
        return $banner;
    }

    public function update($id, $data)
    {
        $data = $this->preExcludeFields($data);
        return $this->model->where('id', $id)->update($data);
    }

    public function delete($id)
    {
        $this->model->where('id', $id)->delete();
        return success('删除成功！');
    }
}
